<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>仿京东问题反馈展开动画案例</title>
    <script src="animate.js" ></script>
    <style>
        .sliderbar{
            position: fixed;
            right: 0;
            bottom: 300px;
            width: 40px;
            height: 40px;
            line-height: 40px;
            text-align: center;
            cursor: pointer;
            color: #fff;
            background-color: purple;
        }

        .con{
            position:absolute;
            left: 0;
            top: 0;
            width: 200px;
            height: 40px;
            background-color: purple;
            z-index: -1;
        }

        a{
            text-decoration:none;
            color: #fff;
        }
    </style>
</head>
<body>
    <div class="sliderbar" >
        <span>←</span>
        <div class="con" ><a href="#">问题反馈</a></div>
    </div>
    <script>
        // 1. 获取元素
        var sliderbar=document.querySelector('.sliderbar');
        var con=document.querySelector('.con');
        // 当我们鼠标经过 sliderbar 就会让 con这个盒子滑动到左侧
        sliderbar.addEventListener('mouseenter',function(){
            animate(con,-160,function(){
                // 当我们动画执行完毕，就把 ← 改为 →
                sliderbar.children[0].innerHTML='→';
            });
        });
        // 当我们鼠标离开 sliderbar 就会让 con这个盒子滑动到右侧
        sliderbar.addEventListener('mouseleave',function(){
            animate(con,0,function(){
                sliderbar.children[0].innerHTML='←';
            });
        });
    </script>
</body>
</html>